<template>
  <div class="topic-container" ref="topic-container">
    <div class="topic-header">
      <h2>专题</h2>
    </div>

    <div class="topic-cards">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
        :immediate-check="false"
        :offset="200"
      >
        <div class="card-container" v-for="item in topicList" :key="item.id">
          <div class="banner">
            <img :src="item.scene_pic_url" alt="" />
          </div>
          <div class="text">
            <p class="title">{{ item.title }}</p>
            <p class="subtitle">{{ item.subtitle }}</p>
            <p class="price_info">{{ item.price_info }}元起</p>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>

<script>
import { listaction } from "@/api/topic";
export default {
  data() {
    return {
      page: 1,
      topicList: [],
      loading: false,
      finished: false,
    };
  },
  methods: {
    async getdata() {
      let res = await listaction({ page: this.page });
      this.loading = false;
      this.topicList.push(...res.data);
    },
    onLoad() {
      if (this.page == 4) {
        this.finished = true;
        return;
      }
      this.page++;
      this.getdata();
    },
  },
  mounted() {
    this.getdata();
  },
};
</script>

<style scoped lang='scss'>
.topic-container {
  .topic-header {
    font-size: 36px;
    color: #333333;
    letter-spacing: 0;
    font-weight: 500;
    padding: 31px 0 21px 0;
    border-bottom: 1px solid rgba(232, 232, 232, 1);
    text-align: center;
  }
  .topic-cards {
    padding: 20px 20px 0 20px;
    background-color: #f8f8f8;
    .card-container {
      .banner {
        height: 343px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .text {
        padding: 32px 0 29px 0;
        text-align: center;
        .title {
          font-size: 30px;
          color: #333333;
          letter-spacing: 0;
          font-weight: 500;
        }
        .subtitle {
          font-size: 26px;
          color: #999999;
          letter-spacing: 0;
          font-weight: 400;
          margin: 4px 0 16px 0;
          @include linedot;
        }
        .price_info {
          font-size: 26px;
          color: #9e4242;
          letter-spacing: 0;
          font-weight: 600;
        }
      }
    }
  }
}
</style>